home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / minix / up1510b.tgz / up1510b / doc / as.doc next >
Text File  |  1990-07-19  |  12KB  |  407 lines

  1. Here is a brief synopis of the MINIX assembly language. It is the same as
  2. IBM's PC/IX assembler.
  3.  
  4. 2.    TOKENS
  5. 2.1    Numbers
  6.  
  7. Same as C
  8.  
  9. 2.2    Character Constants
  10.  
  11. Same as C, supporting \n, \t, \b, \r & \f
  12.  
  13. 2.3    Strings
  14.  
  15. Same as C
  16.  
  17. 2.4    Symbols
  18.  
  19. May contain any letter, digit, ".", "~" or "_", but cannot have a digit or
  20. "~" as the first character.
  21.  
  22. All global names have 8 significant characters
  23.  
  24. The names of the 8086 registers are reserved ([abcd][xlh], [cdes]s, [ds]i,
  25. [sp]p, bx_[ds]i & bp_[ds]i).  The last two forms indicate register pairs;
  26. these names are used in the "base + index" addressing mode (section 6.1).
  27.  
  28. Names of instructions and pseudo-ops are not reserved.  Alphabetic characters
  29. in opcodes and pseudo-ops must be in lower case.
  30.  
  31. 2.5    Separators
  32.  
  33. Commas, blanks, and tabs are separators and can be interspersed freely 
  34. between tokens, but not within tokens (except string and character constants)
  35. or between the tokens of an expression.  Commas are only legal between
  36. operands.
  37.  
  38. 2.6    Comments
  39.  
  40. The command character is "|".
  41.  
  42. 2.7    Opcodes
  43.  
  44. Listed below.
  45.  
  46. Notes:    1) Different names for the same instruction are separated by "/".
  47.     2) Brackets ([]) indicate that 0 or 1 of the enclosed characters
  48.        can be included.
  49.     3) Curly braces ({}) work similarly, except that one of the
  50.        enclosed characters must be included.
  51.  
  52. 2.7.1    Data Transfer 
  53.  
  54. 2.7.1.1    General Purpose 
  55.  
  56.     mov[b]    dest, source    | Move word/byte
  57.     mov{bw}    dest, source    | Move word/byte from source to dest
  58.     pop    dest        | Pop stack 
  59.     push    source        | Push stack 
  60.     xchg    op1, op2    | Exchange word/byte 
  61.     xlat            | Translate 
  62.  
  63. 2.7.1.2    Input/Output
  64.  
  65.     in[w]    source        | Input from source I/O port
  66.     in[w]            | Input from DX I/O port
  67.     out[w]    dest        | Output to dest I/O port
  68.     out[w]            | Output to DX I/O port
  69.  
  70. 2.7.1.3    Address Object
  71.  
  72.     lds    reg,source    | Load reg and DS from source
  73.     les    reg,source    | Load reg and ES from source
  74.     lea    reg,source    | Load effect address of source to reg and DS
  75.     seg    reg        | Specify seg reigster for next instruction
  76.  
  77. 2.7.1.4    Flag Transfer 
  78.  
  79.     lahf            | Load AH from flag register
  80.     popf            | Pop flags 
  81.     pushf            | Push flags 
  82.     sahf            | Store AH in flag register
  83.  
  84. 2.7.2    Arithmetic
  85. 2.7.2.1    Addition
  86.  
  87.     aaa            | Adjust result of BCD addition
  88.     add[b]    dest,source    | Add 
  89.     adc[b]    dest,source    | Add with carry 
  90.     daa            | Decimal Adjust acc after addition
  91.     inc[b]    dest        | Increment by 1
  92.  
  93. 2.7.2.2    Subtraction
  94.  
  95.     aas            | Adjust result of BCD subtraction
  96.     sub[b]    dest,source    | Subtract 
  97.     sbb[b]    dest,source    | Subtract with borrow from dest
  98.     das            | Decimal adjust after subtraction
  99.     dec[b]    dest        | Decrement by one
  100.     neg[b]    dest        | Negate 
  101.     cmp[b]    dest,source    | Compare
  102.     cmp{bw}    dest,source    | Compare
  103.  
  104. 2.7.2.3    Multiplication
  105.  
  106.     aam            | Adjust result of BCD multiply
  107.     imul[b]    source        | Signed multiply
  108.     mul[b]    source        | Unsigned multiply
  109.  
  110. 2.7.2.4    Division
  111.  
  112.     aad            | Adjust AX for BCD divison
  113.     cbw            | Sign extend AL into AH
  114.     cwb            | Sign extend AX into DX
  115.     idiv[b]    source        | Signed divide
  116.     div[b]    source        | Unsigned divide
  117.  
  118. 2.7.3    Bit Manipulation
  119. 2.7.3.1    Logical
  120.  
  121.     and[b]    dest,source    | Logical and
  122.     not[b]    dest        | Logical not
  123.     or[b]    dest,source    | Logical inclusive or
  124.     test[b]    dest,source    | Logical test
  125.     xor[b]    dest,source    | Logical exclusive or
  126.  
  127. 2.7.3.2    Shift
  128.  
  129.     sal[b]/shl[b]    dest,CL        | Shift logical left
  130.     sar[b]        dest,CL        | Shift arithmetic right
  131.     shr[b]        dest,CL        | Shift logical right
  132.  
  133. 2.7.3.3    Rotate
  134.  
  135.     rcl[b]    dest,CL        | Rotate left, with carry
  136.     rcr[b]    dest,CL        | Rotate right, with carry
  137.     rol[b]    dest,CL        | Rotate left
  138.     ror[b]    dest,CL        | Rotate right
  139.  
  140. 2.7.4    String Manipulation
  141.  
  142. The following instructions address source strings through SI and dest string
  143. through DI.
  144.  
  145.     cmp[b]            | Compare
  146.     cmp{bw}            | Compare
  147.     lod{bw}            | Load into AL or AX
  148.     mov[b]            | Move
  149.     mov{bw}            | Move
  150.     rep            | Repeat next instruction until CX=0
  151.     repe/repz        | Repeat next instruction until CX=0 and ZF=1
  152.     repne/repnz        | Repeat next instruction until CX!=0 and ZF=0
  153.     sca{bw}            | Compare string element ds:di with AL/AX
  154.     sto{bw}            | Store AL/AX in ds:di
  155.  
  156. 2.7.5    Control Transfer
  157.  
  158. Displacement is indicated by opcode; "jmp" generates a 16-bit displacement,
  159. and "j" generates 8 bits only.  The provision for "far" labels is described
  160. below.
  161.  
  162. As accepts a number of special branch opcodes, all of which begin with "b".
  163. These are meant to overcome the range limitations of the conditional
  164. branches, which can only reach to targets within -126 to +129 bytes of the
  165. branch ("near" labels).  The special "b" instructions allow the target to
  166. be anywhere in the 64K-byte address space.  If the target is close enough,
  167. a simple conditional branch is used.  Otherwise, the assmebler
  168. automatically changes the instruction into a conditional branch around a
  169. "jmp".
  170.  
  171. The English translation of the opcodes should be obvious, with the possible
  172. exception of the unsigned operations, where "lo" means "lower", "hi" means
  173. "higher", and "s" means "or same".
  174.  
  175. The "call", "jmp", and "ret" instructions can be either intrsegment or
  176. intersegment.  The intersegment versions are indicated with the suffix "i".
  177.  
  178. 2.7.5.1    Unconditional
  179.  
  180.     br    dest        | jump, 16-bit displacement, to dest
  181.     j    dest        | jump, 8-bit displacement, to dest
  182.     call[i]    dest        | call procedure
  183.     jmp[i]    dest        | jump, 16-bit displacement, to dest
  184.     ret[i]            | return from procedure
  185.  
  186. 2.7.5.2    Conditional with 16-bit Displacement
  187.  
  188.     beq            | branch if equal
  189.     bge            | branch if greater or equal (signed)
  190.     bgt            | branch if greater (signed)
  191.     bho            | branch if higher (unsigned)
  192.     bhis            | branch if higher or same (unsigned)
  193.     ble            | branch if less or equal (signed)
  194.     blt            | branch if less (signed)
  195.     blo            | branch if lower (unsigned)
  196.     blos            | branch if lower or same (unsigned)
  197.     bne            | branch if not equal
  198.  
  199. 2.7.5.3    Conditional with 8-bit Displacement
  200.  
  201.     ja/jnbe            | if above/not below or equal (unsigned)
  202.     jae/jnb/jnc        | if above or equal/not below/not carry (unsigned)
  203.     jb/jnae/jc        | if not above nor equal/below/carry (unsigned)
  204.     jbe/jna            | if below or equal/not above (unsigned)
  205.     jg/jnle            | if greater/not less nor equal (signed)
  206.     jge/jnl            | if greater or equal/not less (signed)
  207.     jl/jnqe            | if less/not greater nor equal (signed)
  208.     jle/jgl            | if less or equal/not greater (signed)
  209.     je/jz            | if equal/zero
  210.     jne/jnz            | if not equal/not zero
  211.     jno            | if overflow not set
  212.     jo            | if overflow set
  213.     jnp/jpo            | if parity not set/parity odd
  214.     jp/jpe            | if parity set/parity even
  215.     jns            | if sign not set
  216.     js            | if sign set
  217.  
  218. 2.7.5.4    Iteration Control
  219.  
  220.     jcxz        dest    | jump if CX = 0
  221.     loop        dest    | Decrement CX and jump if CX != 0
  222.     loope/loopz    dest    | Decrement CX and jump if CX = 0 and ZF = 1
  223.     loopne/loopnz    dest    | Decrement CX and jump if CX != 0 and ZF = 0
  224.  
  225. 2.7.5.5    Interrupt
  226.  
  227.     int            | Software interrupt
  228.     into            | Interrupt if overflow set
  229.     iret            | Return from interrupt
  230.  
  231. 2.7.6    Processor Control
  232. 2.7.6.1    Flag Operations
  233.  
  234.     clc            | Clear carry flag
  235.     cld            | Clear direction flag
  236.     cli            | Clear interrupt enable flag
  237.     cmc            | Complement carry flag
  238.     stc            | Set carry flag
  239.     std            | Set direction flag
  240.     sti            | Set interrupt enable flag
  241.  
  242. 2.7.6.2    External Synchronisation
  243.  
  244.     esc    source        | Put contents of source on data bus
  245.     hlt            | Halt until interrupt or reset
  246.     lock            | Lock bus during next instruction
  247.     wait            | Wait while TEST line not active
  248.  
  249. 2.7.7    Floating Point Intructions
  250. 2.7.7.1    Data Transfer
  251. 2.7.7.2    Arithmetic
  252. 2.7.7.3    Comparison
  253. 2.7.7.4 Transcendental
  254. 2.7.7.5 Constant
  255. 2.7.7.6 Process Control
  256.  
  257. 3.    THE LOCATION COUNTER, SEGMENTS AND LABELS
  258. 3.1    Location Counter
  259.  
  260. The special symbol "." is the location counter and its value is the address
  261. of the first byte if the instruction in which the symbol appears and can be
  262. used in expressions.
  263.  
  264. 3.2    Segments
  265.  
  266. There are three different segments: text, data and bss.  The current
  267. segment is selected using the .text, .data or .bss pseudo-ops
  268.  
  269. Note that the "." symbol refers to the location in the current segment.
  270.  
  271. 3.3    Labels
  272.  
  273. There are two types: name and numeric.  Name labels consist of a name
  274. followed by a colon (:).
  275.  
  276. Numeric labels consist of one or more digits followed by a dollar ("$").
  277. Numeric labels are useful because their definition disappears as soon as a
  278. name label is encountered; thus numeric labels can be reused as temporary
  279. local labels.
  280.  
  281. 4.    STATEMENT SYNTA